home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / cross / GBDK-2.0.lha / GBDK / lib / sin_cos.ms < prev    next >
Text File  |  1998-10-01  |  814b  |  74 lines

  1.     INCLUDE "macros.ms"
  2.     .include "math.s"
  3.     .module sin_cos.ms
  4.  
  5.     .area    _BSS
  6. tmp:
  7.     .ds    1
  8.     .area _CODE
  9.  
  10. ; Compute cosine of HLDE
  11. .cos::
  12.     pushf    .pi2
  13.     call    .fadd32
  14. .sin::
  15.     pushf    .onedivtwopi
  16.     call    .fmul32
  17.     call    .dec
  18.     ld    a,h        ; Mul by 4
  19.     ld    c,h        ; Save the sign bit
  20.     and    #0x7f
  21.     inc    a
  22.     inc    a
  23.     bit    7,h
  24.     jr    z,1$
  25.     or    #0x80
  26. 1$:
  27.     ld    h,a
  28. sin_norm:
  29.     cp    #0x42
  30.     jr    z,sin_inc
  31.     or    a
  32.     rr    l
  33.     rr    d
  34.     inc    a
  35.     jr    sin_norm
  36. sin_inc:
  37.     ; Upper 2 bits of l are the quadrant
  38.     ld    b,l
  39.     rl    d
  40.     rl    l
  41.     rl    d
  42.     rl    l    ; l is now the offset into the quadrant
  43.  
  44.     bit    6,b
  45.     jr    z,sin_sense    ; Correct sense
  46.  
  47.     ld    a,l
  48.     cpl
  49.     inc    a
  50.     ld    l,a
  51. sin_sense:
  52.     ld    h,#0
  53.     add    hl,hl
  54.     add    hl,hl
  55.     ld    de,#sin_table
  56.     add    hl,de
  57.  
  58.     ld    e,(hl)
  59.     inc    hl
  60.     ld    d,(hl)
  61.     inc    hl
  62.     ld    a,(hl+)
  63.     ld    h,(hl)
  64.     ld    l,a
  65.     ld    a,b
  66.     and    #0x80
  67.     or    h
  68.     bit    7,c
  69.     jr    z,sin_notneg
  70.     xor    #0x80
  71. sin_notneg:    
  72.     ld    h,a
  73.     ret
  74.